package com.probiz.estore.common.model.system.base;

import java.io.Serializable;
import java.util.Map;
import java.util.HashMap;
import com.probiz.estore.core.model.BaseObject;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

/**
 * AppMenuRole Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class AppMenuRoleTbl extends BaseObject implements Serializable {

	protected AppMenuRolePK appMenuRolePK = new AppMenuRolePK();
	protected com.probiz.estore.common.model.system.AppRole appRole;
	protected com.probiz.estore.common.model.system.AppMenu appMenu;


	/**
	 * Default Empty Constructor for class AppMenuRole
	 */
	public AppMenuRoleTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class AppMenuRole
	 */
	public AppMenuRoleTbl (
		 Integer in_roleId
		,Integer in_menuId
        ) {
		this.setRoleId(in_roleId);
		this.setMenuId(in_menuId);
    }

	
	public com.probiz.estore.common.model.system.AppRole getAppRole () {
		return appRole;
	}	
	
	public void setAppRole (com.probiz.estore.common.model.system.AppRole in_appRole) {
		this.appRole = in_appRole;
		this.getAppMenuRolePK().setRoleId(appRole.getRoleId());
	}
	
	public com.probiz.estore.common.model.system.AppMenu getAppMenu () {
		return appMenu;
	}	
	
	public void setAppMenu (com.probiz.estore.common.model.system.AppMenu in_appMenu) {
		this.appMenu = in_appMenu;
	}
  /**
	* @return appMenuRolePK
	*/
	public AppMenuRolePK getAppMenuRolePK() {
		return this.appMenuRolePK;
	}
	
  /**
	* @set appMenuRolePK
	*/
	public void setAppMenuRolePK(AppMenuRolePK aPrimaryKey) {
		this.appMenuRolePK = aPrimaryKey;
	}
    

	/**
	 * 	 * @return Integer
     * @hibernate.id column="roleId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getRoleId() {
		return this.getAppMenuRolePK().getRoleId();
	}
	
	/**
	 * Set the roleId
	 */	
	public void setRoleId(Integer aValue) {
	    if (aValue==null) {
	    	appRole = null;
	    } else {
	        appRole = new com.probiz.estore.common.model.system.AppRole(aValue);
	        appRole.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
		this.getAppMenuRolePK().setRoleId(appRole.getId());
	}	

	/**
	 * 	 * @return Integer
     * @hibernate.id column="menuId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getMenuId() {
		return this.getAppMenuRolePK().getMenuId();
	}
	
	/**
	 * Set the menuId
	 */	
	public void setMenuId(Integer aValue) {
	    if (aValue==null) {
	    	appMenu = null;
	    } else {
	        appMenu = new com.probiz.estore.common.model.system.AppMenu(aValue);
	        appMenu.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
		this.getAppMenuRolePK().setMenuId(appMenu.getId());
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof AppMenuRoleTbl)) {
			return false;
		}
		AppMenuRoleTbl rhs = (AppMenuRoleTbl) object;
		return new EqualsBuilder()
				.append(this.appMenuRolePK.roleId, rhs.appMenuRolePK.roleId)
				.append(this.appMenuRolePK.menuId, rhs.appMenuRolePK.menuId)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.appMenuRolePK.roleId) 
				.append(this.appMenuRolePK.menuId) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("roleId", this.appMenuRolePK.roleId) 
				.append("menuId", this.appMenuRolePK.menuId) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "roleId";
	}

	/**
	 * Return the primary key as a hashmap
	 */
	public Map getPrimaryKeyMap() {
		
		Map pkMap = new HashMap();
	    pkMap.put("roleId",   this.getRoleId());
	    pkMap.put("menuId",   this.getMenuId());
		return pkMap;
	}

	/**
	 * Return the primary key String as key value pairs
	 */
	public String getPrimaryKeyString() {
		
		java.lang.StringBuffer pkeyString = new java.lang.StringBuffer("[");
	    pkeyString.append("roleId=");
	    pkeyString.append(this.getRoleId());
		pkeyString.append(",");
	    pkeyString.append("menuId=");
	    pkeyString.append(this.getMenuId());
	    pkeyString.append("]");
		return pkeyString.toString();
	}
}